Page({
  /**
   * 页面的初始数据
   */
  data: {
    rules: [{
      name: 'userName',
      rules: {
        required: true,
        message: '用户名是必选项'
      },
    }, {
      name: 'address',
      rules: {
        required: true,
        message: '详细地址是必选项'
      },
    }, {
      name: 'area',
      rules: {
        required: true,
        message: '区域是必选项'
      },
    }, {
      name: 'tel',
      rules: [{
        required: true,
        message: '电话必填'
      }, {
        mobile: true,
        message: '电话格式不对'
      }],
    }],
    radioItems: [
      {name: '男', value: '0', checked: true},
      {name: '女', value: '1'}
  ],
  region:["福建省", "厦门市", "翔安区"],
  isDefault:true,
  scrollViewHeight:0,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let res = wx.getSystemInfoSync();
    let scrollViewHeight = res.windowHeight - 88;
    console.log('scrollViewHeight',scrollViewHeight)
    this.setData({
      scrollViewHeight: scrollViewHeight
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  /**
   * input更改事件
   */
  formInputChange(e){
    const {field} = e.currentTarget.dataset
            this.setData({
                [`formData.${field}`]: e.detail.value
            })
  },
  radioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value);
    var radioItems = this.data.radioItems;
    for (var i = 0, len = radioItems.length; i < len; ++i) {
        radioItems[i].checked = radioItems[i].value == e.detail.value;
    }
    this.setData({
        radioItems: radioItems,
        [`formData.radio`]: e.detail.value
    });
},
bindRegionChange: function (e) {
  console.log('picker发送选择改变，携带值为', e.detail.value)
  this.setData({
    region: e.detail.value
  })
},
/**
 * 保存地址
 */
submitAddress(e){

}
})